<html>
<head><meta charset="utf-8"><title>measuring time spent in traits code · t-compiler/wg-self-profile · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/index.html">t-compiler/wg-self-profile</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/measuring.20time.20spent.20in.20traits.20code.html">measuring time spent in traits code</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="165094819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/measuring%20time%20spent%20in%20traits%20code/near/165094819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/measuring.20time.20spent.20in.20traits.20code.html#165094819">(May 07 2019 at 17:57)</a>:</h4>
<p>I'm curious -- suppose I wanted to measure the amount of time that we spend doing trait solving. I used to use <code>perf</code> for this but I've found that its backtraces have become super unreliable. Could I extend the self-profile to help me get this information?</p>



<a name="165094826"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/measuring%20time%20spent%20in%20traits%20code/near/165094826" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/measuring.20time.20spent.20in.20traits.20code.html#165094826">(May 07 2019 at 17:57)</a>:</h4>
<p>e.g., by adding hooks at various spots in the code?</p>



<a name="165095232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/measuring%20time%20spent%20in%20traits%20code/near/165095232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/measuring.20time.20spent.20in.20traits.20code.html#165095232">(May 07 2019 at 18:01)</a>:</h4>
<p>Absolutely!</p>



<a name="165095270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/measuring%20time%20spent%20in%20traits%20code/near/165095270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/measuring.20time.20spent.20in.20traits.20code.html#165095270">(May 07 2019 at 18:01)</a>:</h4>
<p>If the trait solving is done in a query, then we're already tracking that time under the query</p>



<a name="165095425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/measuring%20time%20spent%20in%20traits%20code/near/165095425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/measuring.20time.20spent.20in.20traits.20code.html#165095425">(May 07 2019 at 18:03)</a>:</h4>
<p>Otherwise, you can use the <code>SelfProfiler::start_activity()</code> and <code>SelfProfiler::end_activity()</code> methods like we do here <a href="https://github.com/rust-lang/rust/blob/767f59462663fbc55a69d39fc5e1f7f83b6fb37d/src/librustc_codegen_llvm/lib.rs#L331-L345" target="_blank" title="https://github.com/rust-lang/rust/blob/767f59462663fbc55a69d39fc5e1f7f83b6fb37d/src/librustc_codegen_llvm/lib.rs#L331-L345">https://github.com/rust-lang/rust/blob/767f59462663fbc55a69d39fc5e1f7f83b6fb37d/src/librustc_codegen_llvm/lib.rs#L331-L345</a></p>



<a name="165096789"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/measuring%20time%20spent%20in%20traits%20code/near/165096789" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/measuring.20time.20spent.20in.20traits.20code.html#165096789">(May 07 2019 at 18:18)</a>:</h4>
<p>thanks <span class="user-mention" data-user-id="125250">@Wesley Wiser</span></p>



<a name="165107603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/measuring%20time%20spent%20in%20traits%20code/near/165107603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/measuring.20time.20spent.20in.20traits.20code.html#165107603">(May 07 2019 at 20:25)</a>:</h4>
<p>I gave this a try and I'm getting data anyway :)</p>



<a name="165142756"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/measuring%20time%20spent%20in%20traits%20code/near/165142756" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/measuring.20time.20spent.20in.20traits.20code.html#165142756">(May 08 2019 at 08:00)</a>:</h4>
<p>Yeah, I think we should add some extra probes for trait code</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>